home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Garbo
/
Garbo.cdr
/
mac
/
source
/
dialgmgr.sit
/
Dialogs ƒ
/
TextGroup.p
< prev
next >
Wrap
Text File
|
1989-11-29
|
3KB
|
132 lines
unit TTextGroup;
{ ⌐1986-1989 Bill Stackhouse }
{ Stackhouse Software }
{ Natick, MA 01760 }
interface
{$IFC UNDEFINED UseTextGroup}
{$SETC UseTextGroup = FALSE}
{$ENDC}
{$IFC UseTextGroup}
uses
TObject;
const
maxTexts = 15;
type
TTextGroup = object(TObject)
numTextGroup: 0..maxTexts; {number of radio/text groups}
TextGroup: array[1..maxTexts] of record
btnNum: Integer; {radio item number}
textNum: Integer; {editText item number}
end;
procedure TTextGroup.Init;
procedure TTextGroup.Add (pBtn: Integer; {pairs of btn and edit text items}
pText: Integer);
procedure TTextGroup.Click (curDialog: dialogPtr;
theItem: Integer);
function TTextGroup.Error: Integer;
end;
{$ENDC}
implementation
{$IFC UseTextGroup}
const
Off = 0;
On = 1;
btnCtrlItem = 4;
chkCtrlItem = 5;
radCtrlItem = 6;
editCtrlItem = 16;
DialogGroupIgnored = -10; {too many groups, key, menus, or user items were added}
type
TSearch = (searching, found, endList);
var
globalError: Integer;
procedure TextClickEdit (curDialog: DialogPtr;
theItem: Integer);
var
theType: Integer;
theHandle: handle;
theBox: Rect;
begin
GetDItem(curDialog, theItem, theType, theHandle, theBox);
if theType = editCtrlItem then
SelIText(curDialog, theItem, 0, 241);
end; {TextClickEdit}
procedure TTextGroup.Init;
begin
globalError := noErr;
SELF.numTextGroup := 0;
end; {TTextGroup.Init}
procedure TTextGroup.Add (pBtn: Integer; {pairs of btn and edit text items}
pText: Integer);
begin
globalError := noErr;
with SELF do
if numTextGroup < maxTexts then
begin
numTextGroup := numTextGroup + 1;
with TextGroup[numTextGroup] do
begin
btnNum := pBtn;
textNum := pText;
end;
end
else
globalError := DialogGroupIgnored;
end; {TTextGroup.Add}
procedure TTextGroup.Click (curDialog: dialogPtr;
theItem: Integer);
var
theType: Integer;
theHandle: handle;
theBox: Rect;
index: Integer;
state: TSearch;
oldValue: Integer;
begin
globalError := noErr;
GetDItem(curDialog, theItem, theType, theHandle, theBox);
if theType = chkCtrlItem then
begin
oldValue := GetCtlValue(ControlHandle(theHandle));
SetCtlValue(ControlHandle(theHandle), BitXor(oldValue, On));
state := searching;
index := 1;
repeat
if (SELF.TextGroup[index].btnNum = theItem) then
state := found
else if index > SELF.numTextGroup then
state := endList
else
index := index + 1;
until (state <> searching);
if (state = found) and (oldValue = Off) then
TextClickEdit(curDialog, SELF.TextGroup[index].textNum);
end;
end; {TTextGroup.Key}
function TTextGroup.Error: Integer;
begin
Error := globalError;
end; {TTextGroup.Error}
{$ENDC}
end.